package main;

public class GeradorNumerosAleatoriosAditivo implements IGeradorNPA{
	private int semente;
	private int bits;
	private int count = 0;
	
	public GeradorNumerosAleatoriosAditivo(int semente, int bits){
		this.semente = semente;
		this.bits = bits;
	}
	
	public int next(){
		return aditivo(count++);
	}
	
	private int aditivo(int n){
		if(n <= 0){
			return semente;
		}
		return (aditivo(n-1) + aditivo(n-count))%bits;
	}
}
